<?php
/**
 * Created by XjHome.
 * User: xj
 * Date: 2015/4/11
 * Time: 0:06
 *
 */
namespace Home\Controller;
class WechatController extends CommonController
{
    private $appID = 'wx313de8a191b57a13';
    private $appsecret = '5f26ab87c7d825c907a541cc39b4fdfa';
    private $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential';
    protected $token;
    protected $token_expires;

    //构造函数，当用户访问此类时获取ACCESS_Token
    public function __construct()
    {
        $this->getTokin();

    }

    //获取TOKEN
    protected function getTokin()
    {
        $url = $this->url . '&appid=' . $this->appID . '&secret=' . $this->appsecret;
        $json_data = file_get_contents($url);
        $token = json_decode($json_data);
        $this->token = $token->access_token;
        $this->token_expires = $token->token_expires;
    }

    //获取服务器IP列表
    public function getServiceIpList()
    {
        $url = 'https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=' . $this->token;
        $json_data = file_get_contents($url);
        $token = json_decode($json_data);
        dump($token);
    }


}